<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Role;

class IndexController extends BaseController{
	
	public function getIndex(){
        return view('index.index');
    }
    
    public function getDashboard(){
        return view('index.dashboard');
    }

    public function getProfile(){
        return view('index.profile');
    }

    public function postModifypwd(){
	    if (\Hash::check(\Input::get('oldpwd'), $this->gadmin->password)) {
	    	$this->gadmin->password=bcrypt(\Input::get('rptpwd'));
	    	$res=$this->gadmin->save();
	    	if($res){
				return redirect('tooltip/success')->with(['redirectway'=>'修改密码成功','redirecturl'=>'/index/profile']);
	    	}
	    	else{
				return redirect('tooltip/failure')->with(['redirectway'=>'修改密码失败','redirecturl'=>'/index/profile']);
	    	}
		}else{
			return redirect('tooltip/failure')->with(['redirectway'=>'原密码不正确，修改密码失败','redirecturl'=>'/index/profile']);
		}
    }
}
